package com.itheima.reggie.exception;

import com.itheima.reggie.entity.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {



    @ExceptionHandler(CustomerException.class)
    public R<String> handlerException(CustomerException e){
        e.printStackTrace();
        return R.error("温馨提示"+e.getMessage());
    }

    /*
     * 以后只要controller出了任何异常都会调用这个方法
     *
     * */
    @ExceptionHandler(Exception.class)
    public R<String> handlerException(Exception e){
        e.printStackTrace();
        return R.error("服务器异常"+e.getMessage());
    }

}
